<extend name="Base/ucmobile_base" />
<!-- addons模块css -->
<block name="style">
 <link href="__STATIC__/datetimepicker/css/datetimepicker.css?v={:SITE_VERSION}" rel="stylesheet" type="text/css">
  <php>if(C('COLOR_STYLE')=='blue_color') echo '
    <link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css?v={:SITE_VERSION}" rel="stylesheet" type="text/css">
    ';</php>
  <link href="__STATIC__/datetimepicker/css/dropdown.css?v={:SITE_VERSION}" rel="stylesheet" type="text/css">
  <link rel="stylesheet" href="{:ADDON_PUBLIC_PATH}/css/app.css">
</block>
<block name="body">
    <header data-am-widget="header" class="am-header am-header-default">
        <div class="am-header-left am-header-nav">
            <a href="#" class="">
                <i class="am-header-icon am-icon-home"></i>
            </a>
            <a href="#phone-link" class="">
                <i class="am-header-icon am-icon-phone"></i>
            </a>
        </div>
        <h1 class="am-header-title">
            <a href="#title-link">微活动</a>
        </h1>
        <div class="am-header-right am-header-nav">
           <a href="{:addons_url ( 'UserCenter://UserCenter/userCenter' )}" class="">
              <i class="am-header-icon am-icon-user"></i>
            </a>
            <a href="#cart-link" class="">
                <i class="am-header-icon am-icon-shopping-cart"></i>
            </a>
        </div>
    </header>
    <div  data-am-widget="slider" class="am-slider am-slider-a1" data-am-slider='{&quot;directionNav&quot;:false}'>
        <ul class="am-slides">
            <empty name="events.cover">
                <li>
                    <img src="{:ADDON_PUBLIC_PATH}/background.png">
                </li>
                <else />
                <li>
                    <img src="{$events.cover}">
                </li>
            </empty>

        </ul>
    </div>
    <section data-am-widget="accordion" class="am-accordion am-accordion-gapped"
             data-am-accordion='{ "multiple": true }'>
        <dl class="am-accordion-item am-active">
            <dt class="am-accordion-title">{$events.title}</dt>
            <dd class="am-accordion-bd am-collapse am-in">
                <!-- 规避 Collapase 处理有 padding 的折叠内容计算计算有误问题， 加一个容器 -->
                <div class="am-accordion-content">
                    <span class="am-icon-clock-o"></span> {$events.start_time|time_format}<br/>
                    <span class="am-icon-map-marker"></span> {$events.address}
                      <notempty name="events.map">
                          <a href="#" data-am-modal="{target: '#doc-modal-1', closeViaDimmer: 0, width: 400, height: 600}">
                              查看地图
                          </a>
                          <div class="am-modal am-modal-no-btn" tabindex="-1" id="doc-modal-1">
                              <div class="am-modal-dialog">
                                  <div class="am-modal-hd">{$events.title}
                                      <a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>&times;</a>
                                  </div>
                                  <div class="am-modal-bd">
                                      <div data-am-widget="map" class="am-map am-map-default" data-longitude="{$events.longitude}" data-latitude="{$events.latitude}"
                                           data-scaleControl="" data-zoomControl="true" data-setZoom="6" data-icon="http://amuituku.qiniudn.com/mapicon.png">
                                          <div id="bd-map"></div>
                                      </div>

                                  </div>
                              </div>
                          </div>
                      </notempty>
                          <br/>
                    <span class="am-icon-file-text"></span> 限额{$events.quota}人<br/>
                    <span class="am-icon-microphone"></span> {$info.public_name}<br/><br/>



                    <div class="am-g">
                        <div class="am-u-sm-12">
                                <button class="am-btn am-btn-default" data-am-modal="{target: '#my-actions'}">
                                    <i class="am-icon-heart-o"></i>收藏/分享
                                </button>
                            <a class="am-btn am-btn-primary" href="#form">
                                我要报名
                            </a>
                        </div>
                    </div>
                    <div class="am-modal-actions" id="my-actions">
                        <div class="am-modal-actions-group">
                            <img src="{:ADDON_PUBLIC_PATH}/images/guide.png" />
                            <ul class="am-list">
                                <li class="am-modal-actions-header">分享</li>
                                <li><a href="#"><span class="am-icon-gift"></span>收藏</a></li>
                            </ul>
                        </div>
                        <div class="am-modal-actions-group">
                            <button class="am-btn am-btn-secondary am-btn-block" data-am-modal-close>取消</button>
                        </div>
                    </div>
            </dd>
        </dl>
        <dl class="am-accordion-item am-active">
            <dt class="am-accordion-title">活动介绍</dt>
            <dd class="am-accordion-bd am-collapse am-in">
                <!-- 规避 Collapase 处理有 padding 的折叠内容计算计算有误问题， 加一个容器 -->
                <div class="am-accordion-content">
                    <article class="am-article">
                    <div class="am-article-hd">
                        <h1 class="am-article-title">{$events.title}</h1>
                        <p class="am-article-meta">{$info.public_name}</p>
                    </div>
                        <div class="am-article-bd">
                            <p class="am-article-lead">
                                {$events.intro}
                            </p>
                            {$events.content}
                    </article>
                </div>
            </dd>
        </dl>
        <dl class="am-accordion-item am-active">
            <dt class="am-accordion-title">报名</dt>
            <dd class="am-accordion-bd am-collapse am-in">
                <!-- 规避 Collapase 处理有 padding 的折叠内容计算计算有误问题， 加一个容器 -->
                <div class="am-accordion-content">

                    <form id="form" action="{:U('add?model='.$model['id'])}" method="post" class="am-form">
                        <fieldset>
                            <!-- 基础文档模型 -->
                            <volist name=":parse_config_attr($model['field_group'])" id="group">
                                <div id="tab{$key}" class="tab-pane <eq name="key" value="1">in
                                </eq>
                                tab{$key}">
                                <volist name="fields[$key]" id="field">
                                    <if condition="$field['is_show'] == 4">
                                        <input type="hidden" class="text input-large" name="{$field.name}" value="{:I($field[name], $field[value])}">
                                    </if>
                                    <if condition="$field['is_show'] == 1 || $field['is_show'] == 3 || ($field['is_show'] == 5 && I($field['name']) )">
                                        <div class="am-form-group">
                                            <label class="item-label">{$field['title']}<span class="check-tips">

                      </span></label>

                                            <switch name="field.type">
                                                <case value="num">
                                                    <input type="text" class="text input-medium" name="{$field.name}" value="{$data[$field['name']]}" placeholder=<notempty name="field['remark']">（{$field['remark']}）</notempty>>
                                                </case>
                                                <case value="string">
                                                    <input type="text" class="text input-large" name="{$field.name}" value="{$data[$field['name']]}" placeholder=<notempty name="field['remark']">（{$field['remark']}）</notempty>>
                                                </case>
                                                <case value="textarea">
                                                    <label class="textarea input-large">
                                                        <textarea name="{$field.name}">{$data[$field['name']]}</textarea>
                                                    </label>
                                                </case>
                                                <case value="datetime">
                                                    <input type="text" name="{$field.name}" class="text input-large time" value="{$data[$field['name']]|time_format}" placeholder="请选择时间" />
                                                </case>
                                                <case value="bool">
                                                    <select name="{$field.name}">
                                                        <volist name=":parse_field_attr($field['extra'])" id="vo"> <option value="{$key}"
                                                            <eq name="data[$field['name']]" value="$key">selected</eq>
                                                            >{$vo}
                                                            </option>
                                                        </volist>
                                                    </select>
                                                </case>
                                                <case value="select">
                                                    <select name="{$field.name}">
                                                        <volist name=":parse_field_attr($field['extra'])" id="vo"> <option value="{$key}"
                                                            <eq name="data[$field['name']]" value="$key">selected</eq>
                                                            >{$vo}
                                                            </option>
                                                        </volist>
                                                    </select>
                                                </case>
                                                <case value="cascade">
                                                    <div id="cascade_{$field.name}"></div>
                                                    {:hook('cascade', array('name'=>$field['name'],'value'=>$data[$field['name']],'extra'=>$field['extra']))}
                                                </case>
                                                <case value="map">
                                                    <div id="map_{$field.name}">
                                                        <input type="hidden" id="longitude" />
                                                        <input type="hidden" id="latitude" />
                                                        <input type="map" class="text input-large" readonly="readonly" id="{$field.name}" name="{$field.name}" value='{$data[$field["name"]]}'>
                                                        {:hook('EasyGo', array('name'=>$field['name'],'value'=>I($field[name], $field[value]),'extra'=>$field['extra']))}
                                                    </div>
                                                </case>
                                                <case value="radio"><br/>
                                                    <volist name=":parse_field_attr($field['extra'])" id="vo">
                                                        <label class="am-radio-inline"> <input type="radio" value="{$key}" name="{$field.name}"
                                                            <eq name="data[$field['name']]" value="$key">checked="checked"</eq>
                                                            >{$vo} </label>
                                                    </volist>
                                                </case>
                                                <case value="checkbox"><br/>
                                                    <volist name=":parse_field_attr($field['extra'])" id="vo">
                                                        <label class="am-checkbox-inline"> <input type="checkbox" value="{$key}" name="{$field.name}[]"
                                                            <in name="key" value="$data[$field['name']]" >checked="checked"</in>
                                                            >{$vo} </label>
                                                    </volist>
                                                </case>
                                                <case value="editor">
                                                    <label class="textarea">
                                                        <textarea name="{$field.name}">{$data[$field['name']]}</textarea>
                                                        {:hook('adminArticleEdit', array('name'=>$field['name'],'value'=>$data[$field['name']]))} </label>
                                                </case>
                                                <case value="picture">

                                                    <input type="file" id="upload_picture_{$field.name}">
                                                    <input type="hidden" name="{$field.name}" id="cover_id_{$field.name}" value="{$data[$field['name']]}"/>
                                                    <div class="upload-img-box">
                                                        <notempty name="data[$field['name']]">
                                                            <div class="upload-pre-item"><img src="__ROOT__{$data[$field['name']]|get_cover='path'}"/></div>
                                                        </notempty>
                                                    </div>
                                                    <p class="am-form-help">请选择要上传的文件...</p>
                                                    <script type="text/javascript">
                                                        //上传图片
                                                        /* 初始化上传插件 */
                                                        $("#upload_picture_{$field.name}").uploadify({
                                                            "height"          : "auto",
                                                            "swf"             : "__STATIC__/uploadify/uploadify.swf",
                                                            "fileObjName"     : "download",
                                                            "buttonText"      : "上传图片",
                                                            "uploader"        : "{:U('home/File/uploadPicture',array('session_id'=>session_id()))}",
                                                            "width"           : 120,
                                                            'removeTimeout'	  : 1,
                                                            'fileTypeExts'	  : '*.jpg; *.png; *.gif;',
                                                            "onUploadSuccess" : uploadPicture{$field.name}
                                                        });
                                                        function uploadPicture{$field.name}(file, data){
                                                            var data = $.parseJSON(data);
                                                            var src = '';
                                                            if(data.status){
                                                                $("#cover_id_{$field.name}").val(data.id);
                                                                src = data.url || '__ROOT__' + data.path;
                                                                $("#cover_id_{$field.name}").parent().find('.upload-img-box').html(
                                                                        '<div class="upload-pre-item"><img src="' + src + '"/></div>'
                                                                );
                                                            } else {
                                                                updateAlert(data.info);
                                                                setTimeout(function(){
                                                                    $('#top-alert').find('button').click();
                                                                    $(that).removeClass('disabled').prop('disabled',false);
                                                                },1500);
                                                            }
                                                        }
                                                    </script>
                                                </case>
                                                <case value="file">

                                                    <input type="file" id="upload_file_{$field.name}">
                                                    <input type="hidden" name="{$field.name}" value="{$data[$field['name']]}"/>
                                                    <div class="upload-img-box">
                                                        <present name="data[$field['name']]">
                                                            <div class="upload-pre-file"><span class="upload_icon_all"></span>{$data[$field['name']]|get_table_field=###,'id','name','File'}</div>
                                                        </present>
                                                    </div>
                                                    <p class="am-form-help">请选择要上传的文件...</p>
                                                    <script type="text/javascript">
                                                        //上传图片
                                                        /* 初始化上传插件 */
                                                        $("#upload_file_{$field.name}").uploadify({
                                                            "height"          : 30,
                                                            "swf"             : "__STATIC__/uploadify/uploadify.swf",
                                                            "fileObjName"     : "download",
                                                            "buttonText"      : "上传附件",
                                                            "uploader"        : "{:U('File/upload',array('session_id'=>session_id()))}",
                                                            "width"           : 120,
                                                            'removeTimeout'	  : 1,
                                                            "onUploadSuccess" : uploadFile{$field.name}
                                                        });
                                                        function uploadFile{$field.name}(file, data){
                                                            var data = $.parseJSON(data);
                                                            if(data.status){
                                                                var name = "{$field.name}";
                                                                $("input[name="+name+"]").val(data.id);
                                                                $("input[name="+name+"]").parent().find('.upload-img-box').html(
                                                                        "<div class=\"upload-pre-file\"><span class=\"upload_icon_all\"></span>" + data.name + "</div>"
                                                                );
                                                            } else {
                                                                updateAlert(data.info);
                                                                setTimeout(function(){
                                                                    $('#top-alert').find('button').click();
                                                                    $(that).removeClass('disabled').prop('disabled',false);
                                                                },1500);
                                                            }
                                                        }
                                                    </script>
                                                </case>
                                                <default/>
                                                <input type="text" class="text input-large" name="{$field.name}" value="{$data[$field['name']]}">
                                            </switch>

                                        </div>
                                    </if>
                                </volist>
                            </volist>
                            <div id="top-alert" class="fixed alert alert-error" style="display: none;">
                                <button class="close fixed" style="margin-top: 4px;">&times;</button>
                                <div class="alert-content"></div>
                            </div>

                            <input type="hidden" name="id" value="{$data.id}">
                            <if condition="empty($data[id]) || $events[can_edit]==1">
                                <button class="am-btn am-btn-default" id="submit" type="submit">确 定</button>
                            </if>

                        </fieldset>
                    </form>

                </div>
            </dd>
        </dl>




    </section>



 </block><!--body end-->
 <block name="script">
 <script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
 <script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script> 
  <script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js?v={:SITE_VERSION}" charset="UTF-8"></script>
<script type="text/javascript">
$('#submit').click(function(){
   // $('#form').submit();
   $.Dialog.loading();
   $.ajax({
	   url:'{:U('add?model='.$model['id'])}',
	   type:'post',
	   data:$('#form').serializeArray(),
	   dataType:'json',
	   success:function(json){
		    //$.Dialog.close();
			if(json.status==1){
			   		
			   		$.Dialog.success(json.info);
					//alert('2');
			   }else{
				   	$.Dialog.fail(json.info);
					//alert('3');
				   }
		   if(json.url!=""){
			   setTimeout(function(){
				   window.location.href=json.url;
				   },2000);
			   }
   		},
		error:function(){
				$.Dialog.close();
			 //$.Dialog.fail();
			}
	   });
});

$(function(){
       $('.time').datetimepicker({
        format: 'yyyy-mm-dd hh:ii',
        language:"zh-CN",
        minView:0,
        autoclose:true
    });

});

wx.config({
    debug: false,
    appId: '{$signPackage['appId']}',
    timestamp: {$signPackage['timestamp']},
    nonceStr: '{$signPackage['nonceStr']}',
    signature: '{$signPackage['signature']}',
    jsApiList: [
        // 所有要调用的 API 都要加到这个列表中
        'onMenuShareTimeline',
        'onMenuShareAppMessage',
        'onMenuShareQQ',
        'onMenuShareWeibo'
    ]
});
wx.ready(function () {
    // 在这里调用 API

    //朋友圈
    wx.onMenuShareTimeline({
        title: '{$events.title}',
        desc: '{$events.intro}',
        link: '{$share_url}',
        imgUrl: '{$events.cover}',
        trigger: function (res) {
            //  alert('用户点击并朋友圈');
        },
        success: function () {
            // 用户确认分享后执行的回调函数
            //  alert('Timeline分享成功');
        },
        cancel: function () {
            // 用户取消分享后执行的回调函数
            //  alert('您取消了分享Timeline');
        }
    });
    wx.onMenuShareAppMessage({
        title: '{$events.title}',
        desc: '{$events.intro}',
        link: '{$share_url}',
        imgUrl: '{$events.cover}',
        type: '', // 分享类型,music、video或link，不填默认为link
        dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
        success: function () {
            //  alert('分享给朋友分享成功');
        },
        cancel: function () {
            //   alert('您取消了分享给朋友');
        }
    });

});
wx.error(function (res) {
    alert(res.errMsg);
});
</script> 
</block>

